//
//  ResetPWDViewController.m
//  HelpThePoor
//
//  Created by van7ish on 2016/12/1.
//  Copyright © 2016年 van7ish. All rights reserved.
//

#import "ResetPWDViewController.h"

@interface ResetPWDViewController ()

/** 头视图 */
@property (nonatomic, strong) UIImageView * headerImageView;
/** 手机图标 */
@property (nonatomic, strong) UIImageView * phoneImageView;
/** 验证码图标 */
@property (nonatomic, strong) UIImageView * idCodeImageView;
/** 密码图标 */
@property (nonatomic, strong) UIImageView * pwdImageView;
/** 手机号输入框 */
@property (nonatomic, strong) UITextField * phoneTextField;
/** 验证码入框 */
@property (nonatomic, strong) UITextField * idCodeTextField;
/** 密码输入框 */
@property (nonatomic, strong) UITextField * pwdTextField;
/** 获取验证码按钮 */
@property (nonatomic, strong) UIButton * idCodeButton;
/** 密码可见按钮 */
@property (nonatomic, strong) UIButton * pwdVisibleButton;
/** 倒计时timer */
@property (nonatomic, strong) NSTimer * timer;
/** 倒计时60s */
@property (nonatomic, assign) NSInteger seconds;
/** 重置密码按钮 */
@property (nonatomic, strong) UIButton * resetButton;
/** 重复密码图标 */
@property (nonatomic, strong) UIImageView * repeatImageView;
/** 重复密码输入框 */
@property (nonatomic, strong) UITextField * repeatTextField;
/** 重复密码可见按钮 */
@property (nonatomic, strong) UIButton * repeatVisibleButton;
/** 返回按钮 */
@property (nonatomic, strong) UIButton * backButton;

/** <#注释#> */
@property (nonatomic, strong) UIView * registWay;
/** <#注释#> */
@property (nonatomic, strong) UIView * registWayID;
/** <#注释#> */
@property (nonatomic, strong) UIView * optionView;
/** <#注释#> */
@property (nonatomic, strong) UIView * nameView;
/** <#注释#> */
@property (nonatomic, strong) UIView * idView;
/** <#注释#> */
@property (nonatomic, strong) UIButton * registWayButton;
/** <#注释#> */
@property (nonatomic, strong) UIView * registWayPhone;
/** <#注释#> */
@property (nonatomic, strong) UIView * registWayCommen;
/** <#注释#> */
@property (nonatomic, strong) UITextField * nameTextField;
/** <#注释#> */
@property (nonatomic, strong) UITextField * idTextField;


@end

@implementation ResetPWDViewController

#pragma mark - lazy load

- (UIView *)registWayPhone{
    if (!_registWayPhone) {
        _registWayPhone = [[UIView alloc] initWithFrame:CGRectMake(0, self.registWay.bottom, SCREEN_W, HeightScale(100))];
        
        _phoneImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(40), HeightScale(21), WidthScale(11.5), HeightScale(18))];
        _phoneImageView.image = ImageNamed(@"number");
        [_registWayPhone addSubview:_phoneImageView];
        
        
        
        _phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(_phoneImageView.right + WidthScale(15), HeightScale(10), SCREEN_W - WidthScale(180), HeightScale(40))];
        _phoneTextField.placeholder = @"输入手机号";
        _phoneTextField.font = FONTSIZE(17);
        
        UIImageView *underLine = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(20), _phoneTextField.bottom - 0.5, SCREEN_W - WidthScale(40), 0.5)];
        underLine.image = ImageNamed(@"fengexian");
        _phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
        _phoneTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [_registWayPhone addSubview:underLine];
        [_registWayPhone addSubview:_phoneTextField];
        
        
        
        _idCodeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(_phoneImageView.left, _phoneTextField.bottom + HeightScale(22), WidthScale(14), HeightScale(16))];
        _idCodeImageView.image = ImageNamed(@"yanzhengma");
        [_registWayPhone addSubview:_idCodeImageView];
        
        
        
        _idCodeTextField = [[UITextField alloc] initWithFrame:CGRectMake(_phoneTextField.left, _phoneTextField.bottom + HeightScale(10), _phoneTextField.width, _phoneTextField.height)];
        _idCodeTextField.placeholder = @"输入验证码";
        _idCodeTextField.font = FONTSIZE(17);
        _idCodeTextField.keyboardType = UIKeyboardTypeNumberPad;
        
        UIImageView *underLine1 = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(20), CGRectGetMaxY(_idCodeTextField.frame), SCREEN_W - WidthScale(40), 0.5)];
        underLine1.image = ImageNamed(@"fengexian");
        _idCodeTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [_registWayPhone addSubview:underLine1];
        [_registWayPhone addSubview:_idCodeTextField];
        
        
        
        _idCodeButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_W - WidthScale(120), _idCodeTextField.frame.origin.y, WidthScale(100), HeightScale(40))];
        [_idCodeButton setTitle:@"获取" forState:UIControlStateNormal];
        _idCodeButton.titleLabel.font = FONTSIZE(17);
        [_idCodeButton setTitle:@"已发送" forState:UIControlStateDisabled];
        [_idCodeButton setTitleColor:COLOR_GREEN forState:UIControlStateNormal];
        [_idCodeButton setTitleColor:COLOR_FONTLIGHTGRAY forState:UIControlStateDisabled];
        [_idCodeButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
        __weak typeof(self) weakSelf = self;
        [_idCodeButton initWithBlock:^(UIButton * idCodeButton) {
            
            [weakSelf requestIDCode];
            
        } for:UIControlEventTouchUpInside];
        [_registWayPhone addSubview:self.idCodeButton];
    }
    return _registWayPhone;
}

- (UIView *)registWayCommen{
    if (!_registWayCommen) {
        _registWayCommen = [[UIView alloc] initWithFrame:CGRectMake(0, self.registWayPhone.bottom, SCREEN_W, HeightScale(100))];

        
        _pwdImageView = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(40), HeightScale(22), WidthScale(14), HeightScale(16))];
        _pwdImageView.image = ImageNamed(@"lock-icon");
        [_registWayCommen addSubview:_pwdImageView];
        
        
        
        _pwdTextField = [[UITextField alloc] initWithFrame:CGRectMake(_pwdImageView.right + WidthScale(15), HeightScale(10), SCREEN_W - WidthScale(180), HeightScale(40))];
        _pwdTextField.placeholder = @"新登录密码";
        _pwdTextField.font = FONTSIZE(17);
        
        UIImageView *underLine = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(20), _pwdTextField.bottom - 0.5, SCREEN_W - WidthScale(40), 0.5)];
        underLine.image = ImageNamed(@"fengexian");
        _pwdTextField.secureTextEntry = YES;
        _pwdTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [_registWayCommen addSubview:_pwdTextField];
        [_registWayCommen addSubview:underLine];
        
        
        
        
        _pwdVisibleButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_W - WidthScale(120), _pwdTextField.frame.origin.y, WidthScale(100), HeightScale(40))];
        [_pwdVisibleButton setTitle:@"显示" forState:UIControlStateNormal];
        _pwdVisibleButton.titleLabel.font = FONTSIZE(17);
        [_pwdVisibleButton setTitle:@"隐藏" forState:UIControlStateSelected];
        [_pwdVisibleButton setTitleColor:COLOR_GREEN forState:UIControlStateNormal];
        [_pwdVisibleButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
        __weak typeof(self)weakSelf = self;
        [_pwdVisibleButton initWithBlock:^(UIButton * pwdVisibleButton) {
            pwdVisibleButton.selected = !pwdVisibleButton.selected;
            if (pwdVisibleButton.selected) {
                DLog(@"显示密码");
                weakSelf.pwdTextField.secureTextEntry = NO;
            } else {
                DLog(@"隐藏密码");
                weakSelf.pwdTextField.secureTextEntry = YES;
            }
        } for:UIControlEventTouchUpInside];
        [_registWayCommen addSubview:_pwdVisibleButton];
    
    
    
        _repeatImageView = [[UIImageView alloc] initWithFrame:CGRectMake(_pwdImageView.left, _pwdTextField.bottom + HeightScale(22), WidthScale(14), HeightScale(16))];
        _repeatImageView.image = ImageNamed(@"lock-icon");
        [_registWayCommen addSubview:_repeatImageView];
        
        
        
        _repeatTextField = [[UITextField alloc] initWithFrame:CGRectMake(_pwdTextField.left, _pwdTextField.bottom + HeightScale(10), _pwdTextField.width, _pwdTextField.height)];
        _repeatTextField.placeholder = @"重复新密码";
        _repeatTextField.font = FONTSIZE(17);
        
        UIImageView *underLine1 = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(20), _repeatTextField.bottom - 0.5, SCREEN_W - WidthScale(40), 0.5)];
        underLine1.image = ImageNamed(@"fengexian");
        _repeatTextField.secureTextEntry = YES;
        _repeatTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [_registWayCommen addSubview:underLine1];
        [_registWayCommen addSubview:_repeatTextField];
        
        
        
        _repeatVisibleButton = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_W - WidthScale(120), _repeatTextField.frame.origin.y, WidthScale(100), HeightScale(40))];
        [_repeatVisibleButton setTitle:@"显示" forState:UIControlStateNormal];
        _repeatVisibleButton.titleLabel.font = FONTSIZE(17);
        [_repeatVisibleButton setTitle:@"隐藏" forState:UIControlStateSelected];
        [_repeatVisibleButton setTitleColor:COLOR_GREEN forState:UIControlStateNormal];
        [_repeatVisibleButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
        [_repeatVisibleButton initWithBlock:^(UIButton * pwdVisibleButton) {
            pwdVisibleButton.selected = !pwdVisibleButton.selected;
            if (pwdVisibleButton.selected) {
                DLog(@"显示新密码");
                weakSelf.repeatTextField.secureTextEntry = NO;
            } else {
                DLog(@"隐藏新密码");
                weakSelf.repeatTextField.secureTextEntry = YES;
            }
        } for:UIControlEventTouchUpInside];
        [_registWayCommen addSubview:_repeatVisibleButton];

    }
    return _registWayCommen;
}

- (UIView *)registWayID{
    if (!_registWayID) {
        _registWayID = [[UIView alloc] initWithFrame:CGRectMake(0, self.registWay.bottom, SCREEN_W, HeightScale(100))];
        
        _nameView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, HeightScale(50))];
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(40), HeightScale(23.5), WidthScale(13.5), HeightScale(13))];
        imageView.image = [UIImage imageNamed:@"name"];
        [_nameView addSubview:imageView];
        
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(imageView.right + WidthScale(15), HeightScale(10), SCREEN_W - WidthScale(180), HeightScale(40))];
        _nameTextField = textField;
        textField.placeholder = @"输入真实姓名";
        textField.font = FONTSIZE(17);
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        [_nameView addSubview:textField];
        [_registWayID addSubview:_nameView];
        UIImageView *underline = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(20), _nameView.bottom - 0.5, SCREEN_W - WidthScale(40), 0.5)];
        underline.image = [UIImage imageNamed:@"fengexian"];
        [_nameView addSubview:underline];
        
        
        
        _idView = [[UIView alloc] initWithFrame:CGRectMake(0, _nameView.bottom, SCREEN_W, HeightScale(50))];
        UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(imageView.left, HeightScale(23), WidthScale(16), HeightScale(14))];
        imageView2.image = [UIImage imageNamed:@"card"];
        [_idView addSubview:imageView2];
        
        UITextField *textField2 = [[UITextField alloc] initWithFrame:CGRectMake(textField.left, HeightScale(10), textField.width, textField.height)];
        _idTextField = textField2;
        textField2.placeholder = @"输入身份证号";
        textField2.font = FONTSIZE(17);
        textField2.clearButtonMode = UITextFieldViewModeWhileEditing;
        [_idView addSubview:textField2];
        [_registWayID addSubview:_idView];
        UIImageView *underline1 = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(20), _idView.height - 0.5, SCREEN_W - WidthScale(40), 0.5)];
        underline1.image = [UIImage imageNamed:@"fengexian"];
        [_idView addSubview:underline1];
        
    }
    return _registWayID;
}

- (UIView *)optionView{
    if (!_optionView) {
        _optionView = [[UIView alloc] initWithFrame:[AppDelegate shareDelegate].window.bounds];
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(self.registWayButton.left, self.registWay.bottom - HeightScale(3), self.registWayButton.width, HeightScale(80))];
        view.backgroundColor = COLOR_DEEPBGCOLOR;
        [_optionView addSubview:view];
        __weak typeof(self)weakSelf = self;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithActionBlock:^(id  _Nonnull sender) {
            [weakSelf.optionView removeFromSuperview];
        }];
        [_optionView addGestureRecognizer:tap];
        
        NSArray *arr = @[@"手机号", @"身份证号"];
        for (int i = 0; i < 2; i++) {
            UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, i * HeightScale(40), view.width, HeightScale(40))];
            [view addSubview:button];
            [button setTitle:arr[i] forState:UIControlStateNormal];
            [button setTitleColor:COLOR_BLACK forState:UIControlStateNormal];
            button.titleLabel.font = FONTSIZE(16);
            [button initWithBlock:^(UIButton *btn) {
                [weakSelf.registWayButton setTitle:btn.titleLabel.text forState:UIControlStateNormal];
                [weakSelf.optionView removeFromSuperview];
                
                [weakSelf.registWayID removeFromSuperview];
                [weakSelf.registWayPhone removeFromSuperview];
                
                if ([btn.titleLabel.text isEqualToString:@"手机号"]) {
                    [weakSelf.view addSubview:weakSelf.registWayPhone];
                    weakSelf.registWayCommen.top = weakSelf.registWayPhone.bottom;
                } else {
                    [weakSelf.view addSubview:weakSelf.registWayID];
                    weakSelf.registWayCommen.top = weakSelf.registWayID.bottom;
                }
                
            } for:UIControlEventTouchUpInside];
        }
    }
    return _optionView;
}

- (UIView *)registWay{
    if (!_registWay) {
        _registWay = [[UIView alloc] initWithFrame:CGRectMake(0, self.headerImageView.bottom + HeightScale(10), SCREEN_W, HeightScale(40))];
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(40), HeightScale(12), WidthScale(14), HeightScale(16))];
        imageView.image = [UIImage imageNamed:@"registerway"];
        [_registWay addSubview:imageView];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(imageView.right + WidthScale(15), 0, WidthScale(80), _registWay.height)];
        label.text = @"找回方式";
        label.font = FONTSIZE(17);
        [_registWay addSubview:label];
        
        
        _registWayButton = [[UIButton alloc] initWithFrame:CGRectMake(label.right, 0, WidthScale(120), _registWay.height)];
        [_registWayButton setTitle:@"手机号" forState:UIControlStateNormal];
        [_registWayButton setTitleColor:COLOR_BLACK forState:UIControlStateNormal];
        _registWayButton.titleLabel.font = FONTSIZE(16);
        [_registWay addSubview:_registWayButton];
        
        UIImageView *sanjiao = [[UIImageView alloc] initWithFrame:CGRectMake(_registWayButton.width - WidthScale(10), (_registWayButton.height - HeightScale(4)) / 2, WidthScale(7), HeightScale(4))];
        sanjiao.image = [UIImage imageNamed:@"sanjiao"];
        sanjiao.userInteractionEnabled = YES;
        [_registWayButton addSubview:sanjiao];
        __weak typeof(self)weakSelf = self;
        [_registWayButton initWithBlock:^(id obj) {
            
            [weakSelf.view addSubview:weakSelf.optionView];
            
        } for:UIControlEventTouchUpInside];
        
        
        UIImageView *underLine = [[UIImageView alloc] initWithFrame:CGRectMake(WidthScale(20), _registWay.height - 0.5, SCREEN_W - WidthScale(40), 0.5)];
        underLine.image = ImageNamed(@"fengexian");
        [_registWay addSubview:underLine];
    }
    return _registWay;
}


- (UIButton *)backButton{
    if (!_backButton) {
        _backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 20, 44, 44)];
        [_backButton setImage:ImageNamed(@"back") forState:UIControlStateNormal];
        _backButton.transform = CGAffineTransformMakeRotation(-M_PI_2);
        __weak typeof(self)weakSelf = self;
        [_backButton initWithBlock:^(id obj) {
            DLog(@"返回");
            [weakSelf dismissViewControllerAnimated:YES completion:nil];
        } for:UIControlEventTouchUpInside];
    }
    return _backButton;
}

- (UIButton *)resetButton{
    if (!_resetButton) {
        _resetButton = [[UIButton alloc] initWithFrame:CGRectMake((SCREEN_W - WidthScale(238)) / 2, SCREEN_H - HeightScale(120), WidthScale(238), HeightScale(61))];
        [_resetButton setImage:ImageNamed(@"chongzhimima_s") forState:UIControlStateNormal];
        __weak typeof(self)weakSelf = self;
        [_resetButton initWithBlock:^(id obj) {
            DLog(@"重置密码");
            if ([_registWayButton.titleLabel.text isEqualToString:@"手机号"]) {
                [weakSelf requestResetPWDWithPhone];
            } else {
                [weakSelf requestResetPWDWithID];
            }
            
            
        } for:UIControlEventTouchUpInside];
    }
    return _resetButton;
}

/** NSTimer selector */
- (void)timerCountdown:(NSTimer *)timer{
    if (self.seconds) {
        [self.idCodeButton setTitle:[NSString stringWithFormat:@"已发送(%lds)", (long)self.seconds] forState:UIControlStateDisabled];
        self.seconds -= 1;
        DLog(@"倒计时 %ld", self.seconds);
    } else {
        [self.idCodeButton setTitle:[NSString stringWithFormat:@"已发送"] forState:UIControlStateDisabled];
        self.idCodeButton.enabled = YES;
        [self.timer invalidate];
        self.timer = nil;
        
    }
    
}

- (UIImageView *)headerImageView{
    if (!_headerImageView) {
        _headerImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, SCREEN_W / 2)];
        _headerImageView.image = ImageNamed(@"background");
        _headerImageView.userInteractionEnabled = YES;
    }
    return _headerImageView;
}

#pragma mark - lify cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = COLOR_LIGHTBGCOLOR;
    [self.view addSubview:self.headerImageView];
    
    [self.view addSubview:self.registWay];
    [self.view addSubview:self.registWayPhone];
    [self.view addSubview:self.registWayCommen];
    
    [self.view addSubview:self.resetButton];
    [self.view addSubview:self.backButton];
    
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    if (_timer) {
        [_timer invalidate];
        _timer = nil;
    }
    
}

- (void)dealloc{
    DLog(@"%s", __func__);
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    [Tool setNavigationBarType:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

#pragma mark - data request

/** 获取短信验证码 */
- (void)requestIDCode{
    if ([Tool isMobileNumber:self.phoneTextField.text]) {
        self.seconds = 60;
        self.idCodeButton.enabled = NO;
        self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerCountdown:) userInfo:nil repeats:YES];
        
        
        NSDictionary *parameters = @{@"userCode": self.phoneTextField.text};
        NSString *URL = [NSString stringWithFormat:KForgetSMSCode, KHostAddress, self.phoneTextField.text];
        [ZRRequestManager POST:URL parameters:parameters success:^(id responseObject) {
            DLog(@"%@", responseObject);
            if ([[responseObject objectForKey:@"error"] integerValue] == 0) {
                [ZRProgressHUD showMsgWithoutView:@"验证码已发送到您的手机"];
            } else {
                [ZRProgressHUD showMsgWithoutView:[responseObject objectForKey:@"data"]];
            }
        } failure:^(NSError *error) {
            DLog(@"获取验证码失败");
        }];
    } else {
        [ZRProgressHUD showMsgWithoutView:@"请输入正确的手机号码"];
    }
}

/** 重置密码 */
- (void)requestResetPWDWithPhone{
    if (![Tool isMobileNumber:self.phoneTextField.text]) {
        [ZRProgressHUD showMsgWithoutView:@"请输入正确的手机号码"];
        return;
    }
    
    if (self.idCodeTextField.text.length == 0) {
        [ZRProgressHUD showMsgWithoutView:@"验证码不能为空"];
        return;
    }
    
    if (self.pwdTextField.text.length == 0) {
        [ZRProgressHUD showMsgWithoutView:@"密码不能为空"];
        return;
    }
    
    if (![self.pwdTextField.text isEqualToString:self.repeatTextField.text]) {
        [ZRProgressHUD showMsgWithoutView:@"两次输入的密码不一致"];
        return;
    }
    
    NSDictionary *parameters = @{@"userCode": self.phoneTextField.text, @"pwd": self.pwdTextField.text, @"verificationCode": self.idCodeTextField.text};
    NSString *URL = [NSString stringWithFormat:KResetPWD, KHostAddress, self.phoneTextField.text, self.pwdTextField.text, self.idCodeTextField.text];
    [ZRRequestManager POST:URL parameters:parameters success:^(id responseObject) {
        DLog(@"%@", responseObject);
        if ([[responseObject objectForKey:@"error"] integerValue] == 0) {
            [ZRProgressHUD showMsgWithoutView:@"重置密码成功"];
            [self dismissViewControllerAnimated:YES completion:nil];
        } else {
            [ZRProgressHUD showMsgWithoutView:[responseObject objectForKey:@"data"]];
        }
    } failure:^(NSError *error) {
        DLog(@"重置密码失败");
    }];
}

- (void)requestResetPWDWithID{
    if (_nameTextField.text.length == 0) {
        [ZRProgressHUD showMsgWithoutView:@"请输入真实姓名"];
        return;
    }
    
    if (![Tool isValidateIDNumber:_idTextField.text]) {
        [ZRProgressHUD showMsgWithoutView:@"非法的身份证号，请重新输入"];
        return;
    }
    
    if (self.pwdTextField.text.length == 0) {
        [ZRProgressHUD showMsgWithoutView:@"密码不能为空"];
        return;
    }
    
    if (![self.pwdTextField.text isEqualToString:self.repeatTextField.text]) {
        [ZRProgressHUD showMsgWithoutView:@"两次输入的密码不一致"];
        return;
    }
    
    NSDictionary *parameters = @{@"userCode": _idTextField.text, @"pwd": self.pwdTextField.text, @"verificationCode": _nameTextField.text};
    NSString *URL = [NSString stringWithFormat:KResetPWD, KHostAddress, _idTextField.text, self.pwdTextField.text, _nameTextField.text];
    [ZRRequestManager POST:URL parameters:parameters success:^(id responseObject) {
        DLog(@"%@", responseObject);
        if ([[responseObject objectForKey:@"error"] integerValue] == 0) {
            [ZRProgressHUD showMsgWithoutView:@"重置密码成功"];
            [self dismissViewControllerAnimated:YES completion:nil];
        } else {
            [ZRProgressHUD showMsgWithoutView:[responseObject objectForKey:@"data"]];
        }
    } failure:^(NSError *error) {
        DLog(@"重置密码失败");
    }];
}

@end
